import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:intl/intl.dart';

//笔记列表
class NoteListScreen extends StatefulWidget {
  const NoteListScreen({super.key});

  @override
  State<NoteListScreen> createState() => _NoteListScreenState();
}

class _NoteListScreenState extends State<NoteListScreen> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('笔记'),
      ),
    );
  }
}

// 编辑笔记
class NoteEditScreen extends StatefulWidget {
  const NoteEditScreen({super.key, required this.day});
  final DateTime day;

  @override
  State<NoteEditScreen> createState() => _NoteEditScreenState();
}

class _NoteEditScreenState extends State<NoteEditScreen> {

  String? title;
  TextEditingController? textEditingController;

  @override
  void initState() {
    super.initState();
    title = DateFormat.MMMd('zh_CN').format(widget.day);
    textEditingController = TextEditingController();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('$title'),
        actions: [
          IconButton(onPressed: (){}, icon: Icon(Icons.delete_rounded))
        ],
      ),
      body: Column(
        children: [
          Expanded(
            child: TextFormField(
                decoration: InputDecoration(
                  contentPadding: EdgeInsets.all(16),
                  focusedBorder: InputBorder.none,
                  border: InputBorder.none
                ),
                style: TextStyle(
                  fontSize: 18
                ),
                expands: true,
                maxLines: null,
                controller: textEditingController,
            ),
          ),
          Container(
            padding: EdgeInsets.symmetric(horizontal: 32,vertical: 8),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                GestureDetector(
                  onTap: (){
                    Get.back();
                  },
                  child: Container(
                    padding: EdgeInsets.symmetric(vertical: 8,horizontal: 64),
                    decoration: BoxDecoration(
                      border: Border.all(),
                      borderRadius: BorderRadius.circular(8)
                    ),
                    child: Text('取消'),
                  ),
                ),
                GestureDetector(
                  onTap: (){
                    Get.back();
                  },
                  child: Container(
                    padding: EdgeInsets.symmetric(vertical: 8,horizontal: 64),
                    decoration: BoxDecoration(
                      color: Colors.green,
                        borderRadius: BorderRadius.circular(8)
                    ),
                    child: Text('保存',style: TextStyle(
                      color: Colors.white,fontSize: 18
                    ),),
                  ),
                ),
              ],
            ),
          ),
          SizedBox(
            height: 16,
          )
        ],
      ),
    );
  }
}

